<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    table tr th, table tr td {
        border-color: #000000;
        text-align: center;
        vertical-align: middle;
        font-size: 16px;
        line-height: 30px
    }

    table tr td input {
        border: none;
        width: 100%;
        height: 30px;
        outline: none;
        text-align: center;
    }

    table tr td textarea {
        border: none;
        width: 100%;
        height: 30px;
        outline: none;
        resize: none;

    }
    .changeCursorIco {
        cursor: pointer;
    }
    .select2{
        margin: 0;
    }

    /**select2 去边框 */
    .selection .select2-selection--single{
        border: none;
    }
    /**select2 下拉菜单中内容居中 */
    .select2-results__option{
        text-align: center;
    }
    /**select2 禁用背景色透明 */
    .select2-container--default.select2-container--disabled .select2-selection--single{
        background: transparent;
    }
    /**select2 去掉三角符 */
    .select2-container--default .select2-selection--single .select2-selection__arrow b {
        border-color: transparent transparent transparent transparent;
        border-style: solid;
        border-width: 5px 4px 0 4px;
        height: 0;
        left: 50%;
        margin-left: -4px;
        margin-top: -2px;
        position: absolute;
        top: 50%;
        width: 0;
    }
</style>
<body class="hold-transition skin-yellow sidebar-mini">
<!--驳回-->
<div class="modal fade" data-backdrop="static" data-keyboard="false" id="modal-reject">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">驳回</h4>
            </div>
            <div class="modal-body">
                <form id="rejectForm" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label for="propRejReaMin" class="col-sm-2 control-label no-padding-right">驳回原因</label>
                        <div class="col-sm-10">
                            <input name="propId" th:value="${prodPla.propId}" type="hidden" style="display: none" />
                            <textarea id="propRejReaMin" class="form-control" name="propRejReaMin" maxlength="500" style="resize: none" rows="9" cols="60"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" shiro:hasPermission="pro:proMinisterialPlanCheck:edit" class="btn btn-info" id="btn_reject_ok">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<section class="content-header">
    <h1>排产计划审核</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box" style="box-shadow: none;border: none;">
                <div class="box-body">
                    <div class="col-md-12 row">
                        <div class="form-inline">
                            <div class="form-group pull-right">
                                <button id="btn_reject" shiro:hasPermission="pro:proMinisterialPlanCheck:edit" type="button" class="btn btn-danger">驳回</button>
                            </div>
                            <div class="form-group pull-right">
                                <button id="btn_agree" shiro:hasPermission="pro:proMinisterialPlanCheck:edit" type="button" class="btn btn-success">同意</button>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-10 col-md-offset-1">
                        <form id="dataForm">

                            <table width="100%" border="1" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td colspan="8"
                                        style="border-left: none;border-right: none;font-size: 20px;height: 35px">
                                        <B>设备类项目排产</B>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 100px;">项目编号</td>
                                    <td style="width:200px;" th:text="${prodOrd.prodNo}"></td>
                                    <td style="width:200px;">项目名称</td>
                                    <td colspan="2" th:text="${prodOrd.prodName}"></td>
                                    <td style="width:200px;">数量</td>
                                    <td colspan="2" th:text="${prodOrd.prodNum}"></td>
                                </tr>
                                <tr>
                                    <td>安装地点</td>
                                    <td th:text="${prodOrd.insSite}"></td>
                                    <td>需方</td>
                                    <td colspan="2" th:text="${prodOrd.customer}"></td>
                                    <td>交货时间</td>
                                    <td colspan="2" th:text="${#dates.format(prodOrd.prodDelDat, 'yyyy-MM-dd')}"></td>
                                </tr>
                                <tr>
                                    <td colspan="8"
                                        style="border-left: none;border-right: none;font-size: 20px;height: 35px">
                                        <B>项目排产</B>
                                    </td>
                                </tr>
                                <tr>
                                    <td>序号</td>
                                    <td>任务名称</td>
                                    <td>开始时间</td>
                                    <td style="width:200px;">结束时间</td>
                                    <td>所属部门</td>
                                    <td>派工工时</td>
                                    <td>备注</td>
                                    <td>变更原因</td>
                                </tr>
                                <tr th:if="${prodPlaDetList.size() > 0 }" th:id="${item.prpdCod}" th:each="item:${prodPlaDetList}">
                                    <td th:text="${itemStat.count}"></td>
                                    <td>
                                        <input name="prpdNam" type="text" readonly="readonly" autocomplete="off"
                                               th:value="${item.prpdNam}"/>
                                    </td>
                                    <td>
                                        <input name="prpdPlaStaDat" type="text" c
                                               readonly="readonly"  th:value="${#dates.format(item.prpdPlaStaDat, 'yyyy-MM-dd')}" onchange="verificationStart(this)"/>
                                    </td>
                                    <td>
                                        <input name="prpdPlaEndDat" type="text"
                                               readonly="readonly"  th:value="${#dates.format(item.prpdPlaEndDat, 'yyyy-MM-dd')}" onchange="verificationEnd(this)"/>
                                    </td>
                                    <td>
                                        <input name="prpdDep" type="text"
                                               th:each="dept : ${#strings.listSplit(item.prpdDepId,',')}"
                                               th:value="${dept}" readonly="readonly"/>
                                    </td>
                                    <td>
                                        <input name="prpdAssWorHours" type="text" style="outline:none;text-align: center;" readonly
                                               th:value="${#strings.defaultString(item.prpdAssWorHours,'')}"/>
                                    </td>
                                    <td>
                                        <textarea name="prpdRem" th:text="${item.prpdRem}" readonly="readonly"></textarea>
                                    </td>
                                    <td>
                                        <textarea name="prpdChaRea" maxlength="255" th:text="${item.prpdChaRea}" readonly="readonly"></textarea>
                                    </td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    /**
     * Jquery 就绪函数
     */
    $(function (){
        /**
         * 模态框隐藏事件， 重置表单，重置验证
         */
        js.modal.hideEvent("modal-reject", function () {
            // js.validate.reset("rejectForm");
            js.reset("rejectForm");
        });

        // /** 验证 */
        // js.validate.init("rejectForm", {
        //     fields: {
        //         propRejRea: {validators: {notEmpty: {message: '尊敬的用户，请输入驳回原因！'}}}
        //     }
        // });

        /**
         * 驳回
         */
        $("#btn_reject").on('click',function (){
            js.modal.open('modal-reject');
        });
        /**
         * 驳回确认
         */
        $("#btn_reject_ok").on('click',function (){
            js.validSubmit({
                formId: "rejectForm",
                url: ctx + "task/ministerialAudit/reject",
                data: new FormData($("#rejectForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        window.opener.reloadTable();
                        window.open('','_self');
                        window.close();
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        });
        /**
         * 同意
         */
        $("#btn_agree").on('click',function (){
            js.confirmPost({
                content: "尊敬的用户，您确认要审批通过此总调计划吗？",
                url: ctx + "task/ministerialAudit/agree",
                data: $("#rejectForm").serialize(),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        window.opener.reloadTable();
                        window.open('','_self');
                        window.close();
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            });
        });
    });
</script>
</body>
</html>